/*
Copyright (C) 2011 Ing. Marek Hubal

This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
*/
#pragma once

#pragma pack(1)
typedef struct {
	int STRUCTURE_SIZE;
	int COMPRESSION_METHOD;
	int PAGE_INDEX;
	unsigned char* RESULT_DATA;
	unsigned int RESULT_DATA_SIZE;
	double ELAPSED_TIME;
	int ERROR_CODE;
} CONVERT_PARAMS, *PCONVERT_PARAMS;

typedef struct {
	__int64 DCREATE;
	unsigned int PAGES_COUNT;
	unsigned int COMPRESSION;
	unsigned int MAX_WIDTH;
	unsigned int MAX_HEIGHT;
	unsigned __int64 ORIGINAL_SIZE;
	unsigned __int64 COMPRESSED_SIZE;
} CBI_STREAM_INFO, *PCBI_STREAM_INFO;
typedef struct {
	unsigned int WIDTH;
	unsigned int HEIGHT;
	unsigned int DPI_X;
	unsigned int DPI_Y;
	unsigned int COLOR_BACK, COLOR_FORE;
	unsigned __int64 COMPRESSED_SIZE;
	unsigned __int64 ORIGINAL_SIZE;
} CBI_PAGE_INFO, *PCBI_PAGE_INFO;

#pragma pack()

extern "C" __declspec(dllimport) void* cbi_create_stream(const char* pFileName, const void* pConvertParams);
extern "C" __declspec(dllimport) int cbi_close_stream(void *pStream, const void* pConvertParams); 
extern "C" __declspec(dllimport) int cbi_add_bmp_page_to_stream(void* pStream, const char* pFileName, const void* pConvertParams);
extern "C" __declspec(dllimport) void* cbi_open_stream(const char* pFileName, const void* pConvertParams);
extern "C" __declspec(dllimport) int cbi_extract_bmp_page(void* pStream, const char* pFileName, int pPageIndex, const void* pConvertParams);
extern "C" __declspec(dllimport) int cbi_get_stream_info(const char* pFileName, PCBI_STREAM_INFO Result);
extern "C" __declspec(dllimport) int cbi_get_pages_info(const char* pFileName, PCBI_PAGE_INFO PagesResult);
extern "C" __declspec(dllimport) void cbi_free_data(void* pData);

#define BMP_ERROR_OPEN_FILE -1
#define BMP_ERROR_READ_FILE -2
#define BMP_ERROR_FILE_HEADER_CORRUPTED -3
#define BMP_ERROR_UNSUPORTED_BITS_PER_PIXEL -4
#define BMP_ERROR_UNSUPORTED_COMPRESSION -5
#define BMP_ERROR_CREATE_FILE -6
#define BMP_ERROR_WRITE_FILE -7

#define CBI_ERROR_CREATE_FILE -100 - 1
#define CBI_ERROR_WRITE_FILE -100 - 2
#define CBI_ERROR_OPEN_FILE -100 - 3
#define CBI_ERROR_READ_FILE -100 - 4
#define CBI_ERROR_INVALID_STRUCTURE -100 - 5
#define CBI_ERROR_PAGE_OUT_OF_RANGE -100 - 6
